/*
 * @Author: zjf
 * @Date: 2023-11-30 13:57:31
 * @LastEditors: zjf
 * @LastEditTime: 2023-12-01 16:18:40
 * @Description: 列表mixins
 */
export default function () {
    return {
        data() {
            return {
                lr_isPage: true,
                // 查询参数
                queryHeight: 44,

                // 表格参数
                tableLoading: false,
                tableData: [],
                tableTotal: 0,
                tableCurrentPage: 1,
                tablePageSize: 50,

                // 表单参数
                formVisible: false,
                formTitle: '',
                formEditRow: null,
                formEdit: false,

                // 详情表单
                formDetail: false,

            }
        },
        computed: {

        },
        mounted() {
            this.init()
        },
        methods: {
            init() {
                this.loadTableData()
            },

            filterBtns(row, btns) {
                return btns
            },
            handleSearch() {
                this.loadTableData()
            },
            turnTablePage({ rows }) {
                this.tablePageSize = rows
                this.loadTableData(true)
            },

            //#region 新增 编辑 详情 表单
            handleAdd() {
                this.formEdit = false
                this.formEditRow = {}
                this.$refs.StageAdd.open({
                    stageInfo: { businessCode: this.formConfig.businessCode, }
                })

            },
            handleEdit($index, row) {
                this.formEdit = true
                this.formEditRow = row
                this.handleShowForm('编辑')
            },
            handleDetails($index, row) {
                this.formEditRow = row
                this.$refs.DetailsDialog.open(row)
            },
            handleShowForm(text) {
                this.formTitle = text
                this.formVisible = true
            },
            async handleOpenedForm(showLoading, hideLoading) {
                if (this.formEdit) {
                    showLoading('加载数据中...')
                    await this.$refs.form.loadFormData(this.formEditRow)
                    hideLoading()
                }
            },
            handleCloseForm() {
                this.formVisible = false
            },
            //#endregion

        }
    }
}